<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="move.js"></script>
<style>
body,ul,ol,li{padding:0;margin:0;}
li{ list-style:none;}
img{ border:0; vertical-align:top;}
#box{width:470px;height:150px;margin:30px auto; position:relative; overflow:hidden;}
ul{ position:absolute;top:0;left:0;}
ul li{width:470px;}
ol{ position:absolute; right:10px; bottom:10px;}
ol li{width:20px; height:20px; line-height:20px; text-align:center;margin-right:5px; background:#fff;color:#f60; float:left;cursor:pointer;}
ol li.on{ background:#f60;color:#fff;}
</style>
<script>
window.onload=function(){
	var ul=document.getElementsByTagName('ul')[0];
	var li=ul.getElementsByTagName('li');
	
	var ol=document.getElementsByTagName('ol')[0];
	var btn=ol.getElementsByTagName('li');
	
	var oneH=li[0].offsetHeight;
	var iNow=0;
	var iNow2=0;
	var timer=null;
	
	var box=document.getElementById('box');
	
	for(var i=0;i<btn.length;i++){
		btn[i].index=i;
		btn[i].onmouseover=function(){
			if(iNow == 0){
				li[0].style.position = 'static';
				ul.style.top = 0;
				iNow2 = 0;
			};
			for(var i=0;i<btn.length;i++){
				btn[i].className='';	
			};
			this.className='on';
			iNow=this.index;
			iNow2=this.index;
			startMove(ul,{top:-this.index*oneH});	
		};	
	};
	
	timer=setInterval(toRun,2000);
	box.onmouseover=function(){
		clearInterval(timer);	
	};
	box.onmouseout=function(){
		timer=setInterval(toRun,2000);
	};
	function toRun(){
		if(iNow==0){
			li[0].style.position='static';
			ul.style.top=0;
			iNow2=0;	
		};
		if(iNow==li.length-1){
			iNow=0;
			li[0].style.position='relative';
			li[0].style.top=li.length*oneH+'px';
		}else{
			iNow++;
		}
		for(var i=0;i<btn.length;i++){
				btn[i].className='';	
		};
		iNow2++;
		btn[iNow].className='on';
		startMove(ul,{top:-iNow2*oneH});	
	};
};
</script>
</head>

<body>
<div id="box">
    <ul>
    	<li><a href="#"><img src="images/1.jpg" width="470" height="150" /></a></li>
    	<li><a href="#"><img src="images/2.jpg" width="470" height="150" /></a></li>
    	<li><a href="#"><img src="images/3.jpg" width="470" height="150" /></a></li>
    	<li><a href="#"><img src="images/4.jpg" width="470" height="150" /></a></li>
    	<li><a href="#"><img src="images/5.jpg" width="470" height="150" /></a></li>
    </ul>
    
    <ol>
    	<li class="on">1</li>
    	<li>2</li>
    	<li>3</li>
    	<li>4</li>
    	<li>5</li>
    </ol>
</div>

</body>
</html>
